<?php
class Options extends CActiveRecord {	
	
	public static function model($className = __CLASS__) {
		return parent::model($className);
	}

	public function tableName() {
		return strtolower('Options');
	}
	
	public function findOptionByName($optionName) {
		$option = Options::model()->find('optionName = "'.$optionName.'"');
		if($option === null) {
			$option = new Options;
			$option->optionName = $optionName;
		}
		return $option;
	}
	
	static public function filterCommaValue($options) {
		function rule($optionValue) {
			if(is_numeric($optionValue)) {
				return $optionValue;
			}
			return 0;
		}
		return array_map('rule', $options);
	}
}
